package cn.sylinx.hbatis.ext.starter.pool;

import java.util.Properties;

import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSourceFactory;

import cn.sylinx.hbatis.log.GLog;

public class Dbcp2DataSourceCreator extends AbstractDataSourceCreator<BasicDataSource> {

	
	@Override
	BasicDataSource createBaseDataSource(String driver, String url, String username, String password, String dbType) {
		Properties p = new Properties();
		p.setProperty("driverClassName", driver);
		p.setProperty("url", url);
		p.setProperty("username", username);
		p.setProperty("password", password);
		try {
			return BasicDataSourceFactory.createDataSource(p);
		} catch (Exception e) {
			GLog.error("createDataSource error", e);
		}
		return null;
	}
}
